﻿using System.Diagnostics;
using System.Linq;
using RatingAuthor;

namespace SamizdatSearch
{
  public class BookViewModel
  {
    public Author Author { get; private set; }
    public string Url { get; private set; }
    public string Title { get; private set; }
    public int Size { get; private set; }
    public string[] Ganres { get; private set; }
    public double Mark { get; private set; }
    public int MarksCount { get; private set; }
    public int CommentsCount { get; private set; }

    public BookViewModel(Book book, GenresLookup genresLookup)
    {
      Author = book.Author;
      Url = book.Url;
      Title = book.Title;
      Size = book.Size;
      Ganres = book.Ganres.Lookup(genresLookup).ToArray();
      Mark = book.Mark;
      MarksCount = book.MarksCount;
      CommentsCount = book.CommentsCount;
    }

    public void GoAuthor()
    {
      Process.Start(Author.FullUrl);
    }
    public void GoBook()
    {
      Process.Start(Author.FullUrl + Url + ".shtml");
    }
  }
}